home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Macintosh Demo Applications CD
/
Apple-MacintoshDemoApplicationsCD-1.0-1992.iso
/
More Information
/
QuicKeys
/
For Programmers Only.sea
/
C Examples
/
SampleX.c
< prev
next >
Wrap
Text File
|
1991-06-22
|
2KB
|
97 lines
/*
$Workfile: SampleX.c $
$Revision: 1.0 $
QuicKeys sample extension execute routine
© 1990 CE Software, Inc. All rights reserved.
For QuicKeys 2 Extension Sample source code you have a royalty-free right
to include object code derived from this Sample source code in programs
that you develop. You also have the right to use, distribute, and license
such programs to third parties without payment of any further license fees
to CE Software, Inc., so long as a copyright notice sufficient to protect
your copyright for your software in the United States or any other country;
is included in the graphic display of your software and on the labels
affixed to the media on which your software is distributed.
WHEN WHO WHAT
•••••
9/5 mkg created version for both MPW and Think C
•••••
*/
#ifndef THINK_C
#include "types.h"
#include "resources.h"
#include "memory.h"
#include "osutils.h"
#include "sound.h"
#endif
#include "extensions.h"
#include "SampleData.h"
#ifdef THINK_C
#include <SetUpA4.h>
#else
#include <osutils.h>
#endif
pascal void
doExecute(short wSelector, SampleData* pMyData, ExecuteQueue* pMyQueue,
short wPeriodicType) {
Handle hSicn;
unsigned long ulNow;
#ifdef THINK_C
RememberA0();
SetUpA4();
#endif
switch (wSelector) {
case initX:
/* fetch our SICN and place it in our ExecuteQueue record */
hSicn = GetResource('SICN', -14348);
if (hSicn != 0)
BlockMove(*hSicn, pMyQueue->sicn, 32);
break;
case regularX:
/* time to do the action called for in our key */
if (pMyData->lWaitTime <= 0) {
SysBeep(1);
}
else {
/*
* need to wait a while before playing.
* Save the time we're going to beep in the refcon, enable
* periodic calls, and exit. Periodic calls will do the rest.
*/
GetDateTime(&ulNow);
pMyQueue->lRefCon = ulNow + (unsigned long)pMyData->lWaitTime;
pMyQueue->flags |= PeriodicFlag;
}
break;
case periodicX:
/* check for the right time to beep */
GetDateTime(&ulNow);
if (ulNow >= (unsigned long)pMyQueue->lRefCon) {
pMyQueue->flags &= ~PeriodicFlag;
SysBeep(1);
}
break;
case abortX:
/* not used */
break;
}
#ifdef THINK_C
RestoreA4();
#endif
}